package com.lab.spring.topicDatabase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * User: bsceran
 * Date: 5/23/13
 * Time: 9:17 AM
 * To change this template use File | Settings | File Templates.
 */
public class Invoker3 {

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("springContext-database.xml");

        VehicleDao vehicleDao = (VehicleDao) applicationContext.getBean("vehicleDao");

        Vehicle bmc = new Vehicle();
        bmc.setVehicleNo(String.valueOf(System.currentTimeMillis()).substring(5,10));
        bmc.setColor("blue");
        bmc.setSeat(12);
        bmc.setWheel(8);
        vehicleDao.insert(bmc);

        for (Vehicle vehicle : vehicleDao.findByNo()) {
            System.out.println("Vehicle No: " + vehicle.getVehicleNo());
        }
    }
}
